package util

import "golang.org/x/crypto/bcrypt"

func BcryptPassword(pwd string) (string, error) {
	encodePwd, err := bcrypt.GenerateFromPassword([]byte(pwd), bcrypt.DefaultCost)
	if err != nil {
		return "", err
	}

	return string(encodePwd), nil
}

func ComparePassword(pwd, comparePwd string) error {
	return bcrypt.CompareHashAndPassword([]byte(pwd), []byte(comparePwd))
}
